Shader "Custom/Projector1" {
	Properties {
		_ShadowTex ("Projected Image(RGB)", 2D) = "white" {}
	}
	SubShader {
		Tags { "RenderType"="Opaque" }
		LOD 200
		
		Pass{
			Blend One One
			
			CGPROGRAM
			#include "UnityCG.cginc"
			#pragma vertex vert
			#pragma fragment frag
			
			sampler2D _ShadowTex;
			float4x4 _Projector;
			
			struct v2f{
				float4 pos:POSITION;
				float4 posProj:TEXCOORD0;
			};
			
			v2f vert(appdata_base i){
				v2f o;
				o.posProj = mul(_Projector,i.vertex);
				o.pos = mul(UNITY_MATRIX_MVP,i.vertex);
				return o;
			}
			
			float4 frag(v2f i):COLOR{
				if(i.posProj.w > 0.0){
					return tex2D(_ShadowTex,i.posProj.xy/i.posProj.w);
				}else{
					return float4(0);
				}
			}
			
			ENDCG
		}
	} 
	FallBack "Diffuse"
}
